#!/usr/bin/perl

  

use strict;

use warnings;

  

# Step 1: Get hold of the main Perl/Tk package.

  

use Tkx;

  

# Step 2: Create the Main Window.  Use the name of the program, 

# held in the special Perl variable $0, to create the title.

  

my $mw = Tkx::widget->new(".");

  

# Step 3: Pack a label onto the screen to hold our initial message.

  

$mw->Label(-text=> "Hello Perl/Tk", -anchor=>'center'

          )->pack(-side=>'top');

  

# Step 4: Create a button to neatly exit the program.

  

$mw->Button( -text=>'Exit', 

             -command=>\&doExit )->pack(-side=>'bottom');

  

# Step 5: Launch the Perl/Tk looping process, to display window.MainLoop(  );



# Step 6: Create an exit subroutine.

Tkx::MainLoop();

sub doExit { exit 0; }
